home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / northc / example2.lzh / mini-hello / crt1.asm < prev    next >
Assembly Source File  |  1990-08-30  |  1KB  |  76 lines

  1. ;  (c) 1990 S.Hawtin.
  2. ;  Permission is granted to copy this file provided
  3. ;   1) It is not used for commercial gain
  4. ;   2) This notice is included in all copies
  5. ;   3) Altered copies are marked as such
  6. ;
  7. ;  No liability is accepted for the contents of the file.
  8. ;
  9. ;
  10. ;  Minimal startup routine for NorthC programs, does not support 
  11. ; memory allocation, command line arguments, Amiga Libraries, and 
  12. ; is very prone to falling over in an untidy heap.  Start from 
  13. ; "crt0.asm" if you want to do any real messing with startup 
  14. ; routines.
  15. ;
  16.     INCLUDE    clibs:clibdefs.i
  17.  
  18.     section ONE,CODE
  19.  
  20.     XREF    __main
  21.     XREF    dosLib
  22. ;
  23. ;        Define entry point
  24. ;
  25.        XDEF    start
  26. start:
  27. ;
  28. ;        Open DOS library
  29. ;
  30.     move.l    #dosname,a1
  31.     clr       d0
  32.     call    exec,OpenLibrary
  33.     move.l    d0,dosLib
  34.     beq    error_exit
  35. ;
  36. ;    Set up file handles
  37. ;
  38.     call    dos,Input
  39.     move.l    d0,__stdin
  40.     beq    error_exit
  41.     call    dos,Output
  42.     move.l    d0,__stdout
  43.     beq    error_exit
  44.     jsr    __main
  45. ;
  46. ;    If _main returns fall through to a normal (0) exit
  47. ;
  48.     move.l    #0,a0
  49.  
  50. a0_exit:
  51.     move.l    a0,-(sp)        ; Hide the return code
  52.  
  53.     move.l    dosLib,a1        ; Close the exec library
  54.     call    exec,CloseLibrary
  55.  
  56.         move.l    (sp)+,a0        ; Send the return to the caller
  57.     rts
  58.  
  59. error_exit:
  60.     move.l    #0,a0
  61.     bra    a0_exit
  62. ;
  63.     section  TWO,data
  64. ;
  65. ;    DOS Library name
  66.  
  67. dosname dc.b    'dos.library',0
  68.  
  69.          section    THREE,bss
  70.  
  71.     xdef    __stdin,__stdout
  72. __stdin  ds.l     1     ;input file handle
  73. __stdout ds.l     1     ;output file handle
  74.  
  75.     END
  76.